package cc.eguid.tools;

import java.util.Objects;

/**
 * 服务配置数据模型
 * @author eguid
 */
public class ServiceConfig {
    private String serviceName;
    private String javaPath;
    private String jarPath;
    private String jvmArgs;
    private String nssmPath; // 该服务专用的NSSM路径
    private boolean loggingEnabled;
    private String logPath;
    private String status; // 服务状态：RUNNING, STOPPED, 等
    private long installTime; // 安装时间戳

    public ServiceConfig() {
        this.installTime = System.currentTimeMillis();
        this.loggingEnabled = true;
        this.jvmArgs = "-Xmx512m";
    }

    public ServiceConfig(String serviceName, String javaPath, String jarPath, String jvmArgs, 
                        String nssmPath, boolean loggingEnabled, String logPath) {
        this();
        this.serviceName = serviceName;
        this.javaPath = javaPath;
        this.jarPath = jarPath;
        this.jvmArgs = jvmArgs;
        this.nssmPath = nssmPath;
        this.loggingEnabled = loggingEnabled;
        this.logPath = logPath;
    }

    // Getters and Setters
    public String getServiceName() {
        return serviceName;
    }

    public void setServiceName(String serviceName) {
        this.serviceName = serviceName;
    }

    public String getJavaPath() {
        return javaPath;
    }

    public void setJavaPath(String javaPath) {
        this.javaPath = javaPath;
    }

    public String getJarPath() {
        return jarPath;
    }

    public void setJarPath(String jarPath) {
        this.jarPath = jarPath;
    }

    public String getJvmArgs() {
        return jvmArgs;
    }

    public void setJvmArgs(String jvmArgs) {
        this.jvmArgs = jvmArgs;
    }

    public String getNssmPath() {
        return nssmPath;
    }

    public void setNssmPath(String nssmPath) {
        this.nssmPath = nssmPath;
    }

    public boolean isLoggingEnabled() {
        return loggingEnabled;
    }

    public void setLoggingEnabled(boolean loggingEnabled) {
        this.loggingEnabled = loggingEnabled;
    }

    public String getLogPath() {
        return logPath;
    }

    public void setLogPath(String logPath) {
        this.logPath = logPath;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public long getInstallTime() {
        return installTime;
    }

    public void setInstallTime(long installTime) {
        this.installTime = installTime;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        ServiceConfig that = (ServiceConfig) o;
        return Objects.equals(serviceName, that.serviceName);
    }

    @Override
    public int hashCode() {
        return Objects.hash(serviceName);
    }

    @Override
    public String toString() {
        return "ServiceConfig{" +
                "serviceName='" + serviceName + '\'' +
                ", status='" + status + '\'' +
                ", installTime=" + installTime +
                '}';
    }
}
